package com.zsc.wxm.ysh.anjo.house.controller;

import com.zsc.wxm.ysh.anjo.house.service.HouseCollectionService;
import com.zsc.wxm.ysh.anjo.result.Result;
import com.zsc.wxm.ysh.anjo.service.base.model.resources.dto.HouseCollectionDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 描述：
 *
 * @author playmaker
 * @since 2021/3/23 23:09
 */
@RestController
@RequestMapping("/house/collection")
public class HouseCollectionController {

    @Resource
    private HouseCollectionService service;

    @PostMapping("/add")
    @ApiOperation("收藏")
    public Result add(@RequestBody HouseCollectionDTO param) {
        service.add(param);
        return Result.ok("收藏成功");
    }



    @GetMapping("list-by-user-id/{userId}")
    @ApiOperation("根据用户id获取收藏的房源")
    public Result listByUserId(@PathVariable("userId") Long userId) {
        Map<String, Object> data = new HashMap<>(1);
        data.put("list", service.listByUserId(userId));
        return Result.ok("获取成功", data);
    }
}
